<%@ page contentType="text/html; charset=utf-8" language="java" errorPage="" %>
<%@ page import="java.sql.*,lee.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>dtree</title>

	<link rel="StyleSheet" href="dtree.css" type="text/css" />
	<script type="text/javascript" src="dtree.js"></script>
</head>
<body>

<div class="dtree">

	<p><a href="javascript: d.openAll();">open all</a> | <a href="javascript: d.closeAll();">close all</a></p>

	<script type="text/javascript">
		d = new dTree('d');
		<%
		DbDao dd = new DbDao("com.mysql.jdbc.Driver", "jdbc:mysql://localhost:3306/test", "root", "root");
		//查询权限树
		Connection conn= dd.getConnection();
		String sql = "select * from class_info";
		Statement stmt = conn.createStatement();
		ResultSet rs = stmt.executeQuery(sql);
		while (rs.next())
		{
			if(rs.getInt("pid") == -1)
			{
			%>	
				var id = <%=rs.getInt("id")%>
				var pid= <%=rs.getInt("pid")%>;
				var name = '<%=rs.getString("name")%>';
				d.add(id,pid,name);			
			<%
			}
			else
			{
			%>
				var id = <%=rs.getInt("id")%>
				var pid= <%=rs.getInt("pid")%>;
				var sequence = '<%=rs.getInt("sequence")%>';
				var name = '<%=rs.getString("name")%>';
				d.add(id,pid,'authority',sequence,name);	
			<%
			}
		}
			%>		
		document.write(d);	
		d.openAll();
		
	</script>

</div>
</body>
</html>